package com.ruoyi.ai.controller;

import com.ruoyi.chatgpt.domain.GptCatalogConfig;
import com.ruoyi.chatgpt.service.IGptCatalogConfigService;
import com.ruoyi.chatgpt.service.IGptCatalogService;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:CatalogController
 * @author: caoes
 * create:2023/6/30 17:13
 **/
@Api(tags = "目录相关接口")
@RestController
@RequestMapping("catalog")
public class CatalogController {

    @Autowired
    private IGptCatalogService gptCatalogService;

    @Autowired
    private IGptCatalogConfigService gptCatalogConfigService;

    @ApiOperation(value = "queryRootGptCatalog", notes = "查询根目录列表")
    @GetMapping("/root")
    public AjaxResult queryRootGptCatalog() {

        return AjaxResult.success(gptCatalogService.queryRootGptCatalog());
    }
    @ApiOperation(value = "queryGptCatalogList", notes = "查询目录子列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "catalogId", value = "目录ID", required = true, dataType = "Long", example = "0")
    })
    @GetMapping("/list")
    public AjaxResult queryGptCatalogList(Long catalogId) {

        return AjaxResult.success(gptCatalogService.queryGptCatalogList(catalogId));
    }

    @ApiOperation(value = "queryGptCatalogConfigList", notes = "查询目录配置列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "catalogId", value = "目录ID", required = true, dataType = "Long", example = "0")
    })
    @GetMapping("/{catalogId}/list")
    public AjaxResult queryGptCatalogConfigList(@PathVariable Long catalogId) {
        GptCatalogConfig gptCatalogConfig = new GptCatalogConfig();
        gptCatalogConfig.setCatalogId(catalogId);
        return AjaxResult.success(gptCatalogConfigService.selectGptCatalogConfigList(gptCatalogConfig));
    }

}
